<template>
  <a-modal
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-descriptions :title="formInfo.title">
      <a-descriptions-item label="问答id">{{ formInfo.rid }}</a-descriptions-item>
      <a-descriptions-item label="题目id">{{ formInfo.questionid }}</a-descriptions-item>
      <a-descriptions-item label="答案">{{ formInfo.anwser }}</a-descriptions-item>
      <a-descriptions-item label="分值">{{ formInfo.score }}</a-descriptions-item>
      <a-descriptions-item label="试卷id">{{ formInfo.wjid }}</a-descriptions-item>
      <a-descriptions-item label="eva_info_id">{{ formInfo.inforid }}</a-descriptions-item>
      <a-descriptions-item label="">{{ formInfo.createTime }}</a-descriptions-item>
    </a-descriptions>
  </a-modal>
</template>

<script>
  import pick from 'lodash.pick'
  import { getAction } from '@/api/manage'

  export default {
    name: 'EvaResultDetailView',
    components: {},
    data () {
      return {
        visible: false,
        confirmLoading: false,
        formInfo: {},
        url: {
          saveInfo: '/system/evaResultDetail/save',
          getInfo: '/system/evaResultDetail/info'
        }
      }
    },
    created () {
    },
    methods: {
      show (record) {
        this.formInfo = Object.assign({}, record)
        if (this.formInfo.id) {
          getAction(this.url.getInfo, { 'id': record.id }).then(res => {
            this.$nextTick(() => {
              this.formInfo = (pick(res.result.data
        , 'id'
        , 'rid'
        , 'questionid'
        , 'anwser'
        , 'score'
        , 'wjid'
        , 'inforid'
        , 'createTime'
              ))
            })
          })
        }
        this.visible = true
      },
                                                                                                      // 确定
      handleSubmit () {
        this.visible = false
      },
      // 关闭
      handleCancel () {
        this.close()
      },
      close () {
        this.visible = false
      }
    }
  }
</script>
